package com.ln.prac.base.m202206.d23.interpret;

/**
 * <pre>
 *  文法中的变量值 - 加法
 * </pre>
 *
 * @Author zhangj
 * @Date 2022/6/23 19:15
 */
public class Plus extends AbstraceExporess{

    /**
     * 定义变量名字
     * @param context
     * @return
     */
    private AbstraceExporess left;
    private AbstraceExporess right;

    public Plus(AbstraceExporess left, AbstraceExporess right) {
        this.left = left;
        this.right = right;
    }

    /**
     * 解释文法
     *
     * @param context
     */
    @Override
    public Integer interpret(Context context) {
        return left.interpret(context) + right.interpret(context);
    }

    @Override
    public String toString() {
        return left + "+" + right;
    }
}
